<!DOCTYPE html>
<html>
<head>
    <title>教师详情 - 学生成绩管理系统</title>
    <link rel="stylesheet" href="/static/css/home.css">
    <link rel="stylesheet" href="/static/css/list.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        .detail-card {
            background: white;
            border-radius: 10px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            padding: 2rem;
            margin: 2rem auto;
            max-width: 800px;
        }

        .detail-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid #eee;
        }

        .detail-title {
            font-size: 1.5rem;
            color: #333;
            margin: 0;
        }

        .detail-id {
            color: #666;
            font-size: 1.1rem;
        }

        .detail-section {
            margin-bottom: 2rem;
        }

        .section-title {
            font-size: 1.2rem;
            color: #444;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid #f0f0f0;
        }

        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1.5rem;
        }

        .info-item {
            margin-bottom: 1rem;
        }

        .info-label {
            display: block;
            color: #666;
            margin-bottom: 0.3rem;
            font-size: 0.9rem;
        }

        .info-value {
            color: #333;
            font-size: 1.1rem;
        }

        .action-buttons {
            display: flex;
            justify-content: flex-end;
            gap: 1rem;
            margin-top: 2rem;
        }

        .btn {
            padding: 0.5rem 1.5rem;
            border-radius: 5px;
            font-size: 1rem;
            cursor: pointer;
            text-decoration: none;
            transition: background-color 0.3s;
        }

        .btn-edit {
            background-color: #4CAF50;
            color: white;
        }

        .btn-delete {
            background-color: #f44336;
            color: white;
        }

        .btn-back {
            background-color: #666;
            color: white;
        }

        .btn:hover {
            opacity: 0.9;
        }

        /* 删除确认对话框样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1000;
        }

        .modal-content {
            background-color: white;
            padding: 2rem;
            border-radius: 10px;
            width: 90%;
            max-width: 500px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .modal-title {
            margin-bottom: 1rem;
            color: #333;
        }

        .modal-buttons {
            display: flex;
            justify-content: flex-end;
            gap: 1rem;
            margin-top: 1.5rem;
        }
    </style>
</head>

<body>
    <!-- 顶部导航栏 -->
    <nav class="top-nav">
        <div class="nav-content">
            <a href="/" class="logo">学生成绩管理系统</a>
            <div class="user-info">
                <span class="welcome-text">欢迎，{{ request.user.username }}</span>
                <a href="{% url 'accounts:logout' %}" class="logout-btn">退出登录</a>
            </div>
        </div>
    </nav>

    <div class="container">
        <main class="main-content">
            <div class="detail-card">
                <div class="detail-header">
                    <div>
                        <h1 class="detail-title">{{ teacher.name }}</h1>
                        <div class="detail-id">工号：{{ teacher.teacher_id }}</div>
                    </div>
                    <span class="status-tag status-active">在职</span>
                </div>

                <div class="detail-section">
                    <h2 class="section-title">基本信息</h2>
                    <div class="info-grid">
                        <div class="info-item">
                            <span class="info-label">院系</span>
                            <span class="info-value">{{ teacher.department }}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">职称</span>
                            <span class="info-value">{{ teacher.title }}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">专业方向</span>
                            <span class="info-value">{{ teacher.specialization|default:"未设置" }}</span>
                        </div>
                        <div class="info-item">
                            <span class="info-label">入职日期</span>
                            <span class="info-value">{{ teacher.hire_date|date:"Y-m-d" }}</span>
                        </div>
                    </div>
                </div>

                <div class="action-buttons">
                    <a href="{% url 'teachers:teacher_list' %}" class="btn btn-back">
                        <i class="fas fa-arrow-left"></i> 返回列表
                    </a>
                    <a href="{% url 'teachers:teacher_edit' teacher.pk %}" class="btn btn-edit">
                        <i class="fas fa-edit"></i> 编辑
                    </a>
                    <a href="#" onclick="showDeleteModal()" class="btn btn-delete">
                        <i class="fas fa-trash"></i> 删除
                    </a>
                </div>
            </div>
        </main>
    </div>

    <!-- 删除确认对话框 -->
    <div id="deleteModal" class="modal">
        <div class="modal-content">
            <h2 class="modal-title">确认删除</h2>
            <p>您确定要删除教师"{{ teacher.name }}"的信息吗？此操作不可撤销。</p>
            <div class="modal-buttons">
                <a href="#" onclick="hideDeleteModal()" class="btn btn-back">取消</a>
                <form action="{% url 'teachers:teacher_delete' teacher.pk %}" method="post" style="display: inline;">
                    {% csrf_token %}
                    <button type="submit" class="btn btn-delete">确认删除</button>
                </form>
            </div>
        </div>
    </div>

    <script>
        function showDeleteModal() {
            document.getElementById('deleteModal').style.display = 'block';
        }

        function hideDeleteModal() {
            document.getElementById('deleteModal').style.display = 'none';
        }

        // 点击模态框外部时关闭
        window.onclick = function(event) {
            var modal = document.getElementById('deleteModal');
            if (event.target == modal) {
                modal.style.display = 'none';
            }
        }
    </script>
</body>
</html>